package com.atguigu.tingshu.order.enums;

import com.atguigu.tingshu.common.constant.SystemConstant;

/**
 * OrderStatusNameEnum 订单状态名称枚举类
 * @author Petrichor
 * @version 2024/01/09 21:17
 **/
public enum OrderStatusNameEnum {

    // 订单枚举项，建立对应关系
    ORDER_STATUS_UNPAID(SystemConstant.ORDER_STATUS_UNPAID , "待支付") ,
    ORDER_STATUS_PAID(SystemConstant.ORDER_STATUS_PAID , "已支付") ,
    ORDER_STATUS_CANCEL(SystemConstant.ORDER_STATUS_CANCEL , "已取消") ;
    // 订单状态码
    private String orderStatus ;
    // 订单状态名称
    private String orderStatusName ;

    OrderStatusNameEnum(String orderStatus , String orderStatusName) {
        this.orderStatus = orderStatus ;
        this.orderStatusName = orderStatusName ;
    }

    /**
     * @description: 定义获取订单状态名称的方法
     * @author Petrichor
     * @date 2024/1/9 21:28
     * @param orderStatus 订单状态码
     * @return 订单状态名称
    **/
    public static String getOrderStatusEnum(String orderStatus) {
        // 获取当前所有枚举类的所有枚举项
        OrderStatusNameEnum[] orderStatusEnums = OrderStatusNameEnum.values();
        for(OrderStatusNameEnum orderStatusEnum : orderStatusEnums) {
            if(orderStatusEnum.orderStatus.equals(orderStatus)) {
                return orderStatusEnum.orderStatusName ;
            }
        }
        return "" ;
    }

}

